import request from "@/utils/request";
import type {
    majorInfoData,
    majorListFormData,
    majorResponseData,
    majorAllResponseData,
    majorListResponseData
} from "./type"

enum API{
    MAJOR_ALL_URL="/manage/major/all",
    MAJOR_LIST_URL = "/manage/major/list",  //筛选项
    MAJOR_ADD_URL = "/manage/major/add",  //添加项
    MAJOR_GET_ID_URL="/manage/major/find", //获取id
    MAJOR_UPDATE_URL="/manage/major/update", //修改
    MAJOR_DELETE_URL= "/manage/major/delete"
}
    export const reqMajorAll = ()=>
    request.get<any,majorAllResponseData>(API.MAJOR_ALL_URL)
    // 读筛选项
    export const reqMajorList = (data:majorListFormData)=>
    request.post<any,majorListResponseData>(API.MAJOR_LIST_URL,data)
     // 添加
    export const reqMajorAdd = (data:majorInfoData)=>
    request.post<any,majorResponseData>(API.MAJOR_ADD_URL,data)
  
    //修改
    export const reqMajorById = (_id:string)=>
    request.get<any,majorResponseData>(API.MAJOR_GET_ID_URL+`?_id=${_id}`)

    export const reqMajorUpdata = (data:majorInfoData)=>
    request.post<any,majorResponseData>(API.MAJOR_UPDATE_URL,data)
     // 删除
    export const reqMajorDelete = (majorId:string)=>
    request.post<any,majorResponseData>(API.MAJOR_DELETE_URL,{majorId})